package com.mall.manager.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import com.mall.common.dao.MongoDBManager;
import com.mongodb.DBObject;
/**
 * 全国人数分类统计信息业务层
 * @ClassName: DiffPeopleService
 * @Description: 
 * @author:wangwenyue wangwenyue@ide365.com
 * @date 2016年7月12日 下午2:23:11
 */
@Service
public class DiffPeopleService {

	Logger logger=LoggerFactory.getLogger(DiffPeopleService.class);
	/**
	 * 获取mongodb 数据
	 * @return
	 */
	public List<String> findDiffPeo() {
		List<DBObject> findAll = MongoDBManager.findAll("php_school");
		List<String> stingList = new ArrayList<String>();
		String res3;
		for (DBObject dbObject : findAll) {
			String string = String.valueOf(dbObject.get("city"));
			String string2 = String.valueOf(dbObject.get("area"));
			String string3 = String.valueOf(dbObject.get("province"));
			res3 = "school,s1"+string+",s2"+string2+",s3"+string3;
			stingList.add(res3);
		}
		return stingList;
	}
	
	
	
	/**
	 * 获取宝宝的数据
	 */
	public List<String> findAllBaby() {
		List<String> ldb = new ArrayList<String>();
		List<DBObject> findAll = MongoDBManager.findAll("php_baby");
		Map<String, Object> tj=null;
		String city = "";
		String area =  "";
		String province = "";
		String res ="";
		for (DBObject dbObject : findAll) {
			tj = new HashMap<String, Object>();
			tj.put("id", dbObject.get("school_id"));
			DBObject findOne = MongoDBManager.findOne("php_school", tj);
			if(findOne!=null && !findOne.equals("null")){
				city = String.valueOf(findOne.get("city"));
				area = String.valueOf(findOne.get("area"));
				province = String.valueOf(findOne.get("province"));
				res = "baby,b1"+city+",b2"+area+",b3"+province;
				ldb.add(res);
			}
		}
		return ldb;
	}
	
	/**
	 * 获取班级数据
	 * @return
	 */
	public List<String> findAllClass() {
		List<String> ldb = new ArrayList<String>();
		List<DBObject> findAll = MongoDBManager.findAll("php_class");
		Map<String, Object> tj=null;
		String city = "";
		String area =  "";
		String province = "";
		String res ="";
		for (DBObject dbObject : findAll) {
			tj = new HashMap<String, Object>();
			tj.put("id", dbObject.get("school_id"));
			DBObject findOne = MongoDBManager.findOne("php_school", tj);
			if(findOne!=null && !findOne.equals("null")){
				city = String.valueOf(findOne.get("city"));
				area = String.valueOf(findOne.get("area"));
				province = String.valueOf(findOne.get("province"));
				res = "class,c1"+city+",c2"+area+",c3"+province;
				ldb.add(res);
			}
		}
		return ldb;
	}
	
	
	
	
	
	

}
